{% extends "admin/layout.html" %}
{% set active_page = "members" %}

{% block content %}
<div class="container-fluid">
    <h2 class="mb-4">人员信息</h2>

    <div class="card shadow-sm mb-4">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h5 class="mb-0">成员列表</h5>
            <div>
                <div class="input-group">
                    <input aria-label="搜索成员" class="form-control" placeholder="搜索成员..." type="text">
                    <button class="btn btn-outline-secondary" type="button">
                        <i class="fas fa-search"></i>
                    </button>
                </div>
            </div>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>姓名</th>
                        <th>企业微信ID</th>
                        <th>部门</th>
                        <th>职位</th>
                        <th>手机</th>
                        <th>标签</th>
                        <th>状态</th>
                        <th>群组状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for user in users %}


                    <tr>
                        <td>
                            <div class="d-flex align-items-center">
                                <strong>{{ user.name }}</strong>
                            </div>
                        </td>
                        <td>{{ user.wecom_userid }}</td>
                        <td>{{ user.department.name if user.department else '未分配部门' }}</td>
                        <td>{{ user.position }}</td>
                        <td>{{ user.mobile }}</td>
                        <td>{{ user.tags }}</td>
                        <td>
                            {% if user.status == 1 %}
                            <span class="badge bg-success">已激活</span>
                            {% elif user.status == 2 %}
                            <span class="badge bg-danger">已禁用</span>
                            {% else %}
                            <span class="badge bg-secondary">未激活</span>
                            {% endif %}
                        </td>
                        <td>
                            {% if user.in_groups %}
                            <span class="badge bg-success">已入群</span>
                            {% else %}
                            <span class="badge bg-warning">未入群</span>
                            {% endif %}
                        </td>
                        <td>
                            <div class="btn-group">
                                <button class="btn btn-sm btn-outline-info" title="查看详情">
                                    <i class="fas fa-eye"></i>
                                </button>
                                <button class="btn btn-sm btn-outline-primary" title="手动拉群">
                                    <i class="fas fa-user-plus"></i>
                                </button>
                            </div>
                        </td>
                    </tr>
                    {% else %}
                    <tr>
                        <td class="text-center" colspan="8">没有成员数据，请先同步</td>
                    </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>

            <!-- 分页 -->
            <nav aria-label="成员分页">
                <ul class="pagination justify-content-center">
                    <li class="page-item disabled">
                        <a class="page-link" href="#" tabindex="-1">上一页</a>
                    </li>
                    <li class="page-item active"><a class="page-link" href="#">1</a></li>
                    <li class="page-item"><a class="page-link" href="#">2</a></li>
                    <li class="page-item"><a class="page-link" href="#">3</a></li>
                    <li class="page-item">
                        <a class="page-link" href="#">下一页</a>
                    </li>
                </ul>
            </nav>
        </div>
    </div>


</div>
{% endblock %}